<?php
    if($userid!=get_admin_user_id()){
	     die("failed");
    }
    if(isset($_POST["app_location"])){
    	$app_location=$_POST["app_location"];
    }
    else{
    	die("failed");
    }
    if(isset($_POST["act"])&&$_POST["act"]=="install"){
    	$app_profile=$app_location."/application.php";
    	if(file_exists($app_profile)){
    		require $app_profile;
    		$sql="insert into application(`name`,`showname`,`description`,`frontpage`,`location`) values ('".$app_name."','".$app_slug_name."','".$app_description."','".$app_frontpage."','".$app_location."')";
    		$res=execute_sql_silent($sql);
    		if($res[0]){
    			exit("success");
    		}
    		else{
    			die("failed");
    		}
    	}
    	else{
    		die("failed");
    	}
    }elseif(isset($_POST["act"])&&$_POST["act"]=="delete"){
    	$sql="delete from application where `location`='".$app_location."'";
    	$res=execute_sql_silent($sql);
    	if($res[0]){
    		exit("success");
    	}
    	else{
    		die("failed");
    	}
    }else{
    	die("failed");
    }
?>